<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改产品安装信息')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-partsQrcodeInstall-edit" th:object="${zsyhPartsQrcodeInstall}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">产品名称：</label>
                        <div class="col-sm-8">
                            <input name="partsId" th:field="*{partsName}" class="form-control" type="text" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">规格名称：</label>
                        <div class="col-sm-8">
                            <input name="attributeId" th:field="*{attributeName}" class="form-control" type="text" readonly>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">安装店铺：</label>
                        <div class="col-sm-8">
                            <input name="userName" th:field="*{userName}" class="form-control" type="text" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">联系方式：</label>
                        <div class="col-sm-8">
                            <input name="userPhone" th:field="*{userPhone}" class="form-control" type="text" readonly>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">二维码有效期：</label>
                        <div class="col-sm-8">
                            <input name="installPeriod" th:field="*{installPeriod}" class="form-control" type="text" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">二维码编码：</label>
                        <div class="col-sm-8">
                            <input name="qrcodeId" th:field="*{qrcodeId}" class="form-control" type="text" readonly>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">补助金有效期：</label>
                        <div class="col-sm-8">
                            <input name="warrantyPeriod" th:field="*{warrantyPeriod}" class="form-control" type="text" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">补助金金额：</label>
                        <div class="col-sm-8">
                            <input name="payPrice" th:field="*{payPrice}" class="form-control" type="text" readonly>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">保质期：</label>
                        <div class="col-sm-8">
                            <input name="qualityPeriod" th:field="*{qualityPeriod}" class="form-control" type="text" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">安装日期：</label>
                        <div class="col-sm-8">
                            <input name="createTime" th:value="${#dates.format(zsyhPartsQrcodeInstall.createTime, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" placeholder="yyyy-MM-dd hh:mm:ss" type="text" readonly>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">安装凭证：</label>
                        <div class="col-sm-10">
                            <input type="hidden" name="installImages" th:field="*{installImages}">
                            <div class="file-loading">
                                <input class="form-control file-upload" id="installImages" name="file" type="file">
                            </div>
                        </div>
                    </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/partsQrcodeInstall";
        $("#form-partsQrcodeInstall-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-partsQrcodeInstall-edit').serialize());
            }
        }

        $(".file-upload").each(function (i) {
            debugger;
            var val = $("input[name='" + this.id + "']").val();
            var imageArr = val.split("|");
            $(this).fileinput({
                'uploadUrl': ctx + 'common/uploadOSS',
                initialPreviewAsData: true,
                initialPreview: imageArr,
                maxFileCount: 1,
                showRemove: false,/*是否显示移除按钮*/
                showUpload: false,/*是否显示上传按钮*/
                showBrowse: false,/*是否显示浏览按钮,选择按钮*/
                showCaption: false, /*是否显示被选文件的简介*/
                autoReplace: true,
                layoutTemplates: {
                    actionDelete:'',
                    actionUpload:''
                } /*去掉缩略图上的删除和上传按钮*/
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>